home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / DOMAIN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-24  |  5.4 KB  |  200 lines

  1. #ifndef    _DOMAIN_H
  2. #define    _DOMAIN_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifndef    _MBUF_H
  9. #include "mbuf.h"
  10. #endif
  11.  
  12. #ifndef _PROC_H
  13. #include "proc.h"
  14. #endif
  15.  
  16. #define    MAXCNAME    10    /* Maximum amount of cname recursion */
  17.  
  18. #define    TYPE_A        1    /* Host address */
  19. #define    TYPE_NS        2    /* Name server */
  20. #define    TYPE_MD        3    /* Mail destination (obsolete) */
  21. #define    TYPE_MF        4    /* Mail forwarder (obsolete) */
  22. #define    TYPE_CNAME    5    /* Canonical name */
  23. #define    TYPE_SOA    6    /* Start of Authority */
  24. #define    TYPE_MB        7    /* Mailbox name (experimental) */
  25. #define    TYPE_MG        8    /* Mail group member (experimental) */
  26. #define    TYPE_MR        9    /* Mail rename name (experimental) */
  27. #define    TYPE_NULL    10    /* Null (experimental) */
  28. #define    TYPE_WKS    11    /* Well-known sockets */
  29. #define    TYPE_PTR    12    /* Pointer record */
  30. #define    TYPE_HINFO    13    /* Host information */
  31. #define    TYPE_MINFO    14    /* Mailbox information (experimental)*/
  32. #define    TYPE_MX        15    /* Mail exchanger */
  33. #define    TYPE_TXT    16    /* Text strings */
  34. #define TYPE_INCLUDE    17    /* $include entries */
  35. #define    TYPE_AXFR    252    /* Transfer zone of athority */
  36. #define    TYPE_MAILB    253    /* Transfer mailbox records */
  37. #define    TYPE_MAILA    254    /* Transfer mail agent records */
  38. #define    TYPE_ANY    255    /* Matches any type */
  39.  
  40. #define    CLASS_IN    1    /* The ARPA Internet */
  41. #define    CLASS_CH    3    /* The CHAOS net at MIT */
  42. #define    CLASS_ANY    255    /* wildcard match */
  43.  
  44. struct dserver {
  45.     struct dserver *prev;    /* Linked list pointers */
  46.     struct dserver *next;
  47.  
  48.     uint32 address;        /* IP address of server */
  49.     int16 port;        /* TCP port for request */
  50.     int32 timeout;        /* Current timeout, ticks */
  51.     int32 srtt;        /* Smoothed round trip time, ticks */
  52.     int32 mdev;        /* Mean deviation, ticks */
  53.     int32 queries;        /* Query packets sent to this server */
  54.     int32 responses;    /* Response packets received from this server */
  55.     int32 timeouts;        /* Query timeouts (misses) */
  56. };
  57. #define    NULLDOM    (struct dserver *)0
  58.  
  59. /* Round trip timing parameters */
  60. #ifndef AGAIN
  61. #define    AGAIN    8    /* Average RTT gain = 1/8 */
  62. #define    LAGAIN    3    /* Log2(AGAIN) */
  63. #define    DGAIN    4    /* Mean deviation gain = 1/4 */
  64. #define    LDGAIN    2    /* log2(DGAIN) */
  65. #endif
  66.  
  67. #define DOM_RESPONSE    0x8000
  68. #define    DOM_AUTHORITY    0x0400
  69. #define    DOM_TRUNC    0x0200
  70. #define    DOM_DORECURSE    0x0100
  71. #define    DOM_CANRECURSE    0x0080
  72.  
  73. /* Header for all domain messages */
  74. struct dhdr {
  75.     int16 id;        /* Identification */
  76.     char qr;        /* Query/Response */
  77. #define    QUERY        0
  78. #define    RESPONSE    1
  79.     char opcode;
  80. /*      QUERY       0        */
  81. #define IQUERY      1
  82. #define DOMSTATUS   2
  83. #define    ZONEINIT    14
  84. #define ZONEREF     15
  85.     char aa;        /* Authoratative answer */
  86.     char tc;        /* Truncation */
  87.     char rd;        /* Recursion desired */
  88.     char ra;        /* Recursion available */
  89.     char rcode;        /* Response code */
  90. #ifndef NO_ERROR
  91. #define    NO_ERROR    0
  92. #endif
  93. #define    FORMAT_ERROR    1
  94. #define    SERVER_FAIL    2
  95. #define    NAME_ERROR    3
  96. #define    NOT_IMPL    4
  97. #define    REFUSED        5
  98.     int16 qdcount;        /* Question count */
  99.     int16 ancount;        /* Answer count */
  100.     int16 nscount;        /* Authority (name server) count */
  101.     int16 arcount;        /* Additional record count */
  102.     struct rr *questions;    /* List of questions */
  103.     struct rr *answers;    /* List of answers */
  104.     struct rr *authority;    /* List of name servers */
  105.     struct rr *additional;    /* List of additional records */
  106. };
  107.  
  108. struct mx {
  109.     int16 pref;
  110.     char *exch;
  111. };
  112.  
  113. struct hinfo {
  114.     char *cpu;
  115.     char *os;
  116. };
  117.  
  118. struct minfo {
  119.     char *rmailbx;
  120.     char *emailbx;
  121. };
  122.  
  123. #if 0
  124. struct wks {
  125.     uint32 addr;
  126.     unsigned char protocol;
  127.     unsigned char bitmap[64];
  128. };
  129. #endif
  130.  
  131. struct soa {
  132.     char *mname;
  133.     char *rname;
  134.     int32 serial;
  135.     int32 refresh;
  136.     int32 retry;
  137.     int32 expire;
  138.     int32 minimum;
  139. };
  140.  
  141. struct rr {
  142.     struct rr *last;
  143.     struct rr *next;
  144.     char source;
  145. #define RR_NONE        0
  146. #define RR_FILE        1    /* from file */
  147. #define RR_QUESTION    4    /* from server reply */
  148. #define RR_ANSWER    5    /* from server reply */
  149. #define RR_AUTHORITY    6    /* from server reply */
  150. #define RR_ADDITIONAL    7    /* from server reply */
  151. #define RR_QUERY    8    /* test name (see QUERY)*/
  152. #define RR_INQUERY    9    /* test resource (see IQUERY)*/
  153.  
  154.     char *comment;        /* optional comment */
  155.     char *name;        /* Domain name, ascii form */
  156.     char *suffix;        /* Suffix name */
  157.     int32 ttl;        /* Time-to-live */
  158. #ifdef __GNUC__
  159. #define TTL_MISSING    0x80000000LU
  160. #else
  161. #define TTL_MISSING    0x80000000L
  162. #endif
  163.     int16 class;        /* IN, etc */
  164. #define CLASS_MISSING    0
  165.     int16 type;        /* A, MX, etc */
  166. #define TYPE_MISSING    0
  167.     int16 rdlength;        /* Length of data field */
  168.     union {
  169.         uint32 addr;        /* Used for type == A */
  170.         struct soa soa;        /* Used for type == SOA */
  171.         struct mx mx;        /* Used for type == MX */
  172.         struct hinfo hinfo;    /* Used for type == HINFO */
  173.         struct minfo minfo;    /* Used for type == MINFO */
  174. #if 0
  175.         struct wks wks;        /* Used for type == WKS */
  176. #endif
  177.         char *name;        /* for domain names */
  178.         char *data;        /* for anything else */
  179.     } rdata;
  180. };
  181. #define    NULLRR    (struct rr *)0
  182.  
  183. extern struct proc *Dfile_updater;
  184. extern int DTranslate;
  185. extern int DVerbose;
  186.  
  187. /* In domain.c */
  188. void free_rr (struct rr *rrlp);
  189. struct rr *inverse_a (uint32 ip_address);
  190. char *resolve_a (uint32 ip_address, int shorten);
  191. struct rr *resolve_mailb (const char *name);
  192. int add_nameserver (uint32 address,int timeout);
  193. char *domainsuffix (const char *dname);
  194.  
  195. /* In domhdr.c: */
  196. int ntohdomain (struct dhdr *dhdr,struct mbuf **bpp);
  197. int htondomain (struct dhdr *dhdr,char *buf,int16 len);
  198.  
  199. #endif    /* _DOMAIN_H */
  200.